<?php
namespace Application\Controller;

use Application\Model\Dao\UpdateDao;
use Application\Service\XmlService;
use Zend\Authentication\AuthenticationService;
use Zend\View\Model\ViewModel;
use Zend\View\Model\JsonModel;
use Application\Service\ImageService;
use Application\Service\UpdateService;

class MessageController extends LoginAwareController
{

    


    /**
     * @return JsonModel
     * Get all discussion data.
     */
    public function saveDiscussion()
    {
        $request = $this->getRequest();
        if ($request->isPost()) {
            $discussion = $request->getPost('dicussion');
            $title = $request->getPost('title');
            $targetType = $request->getPost('targetType');
            $targetId = $request->getPost('targetId');
            $photoSet = $this->getUploadedFileXml('attached');
            $loginId = $this->getLoggedinUserId();
            $updateDao =  $this->getServiceLocator()->get('update');
            $updateDao->saveUpdateData($discussion, $loginId, $photoSet, null, UpdateDao::$UPDATE_TYPE['DISCUSSION'], $targetType, $targetId);
            $data = array(
                'result' => 'success'
            );
            return new JsonModel($data);
        }
    }
}

?>